#include <iostream>
#include <cstdlib>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    //Initialize Varibles
    int seed, num_students, grade, a = 0, b = 0, c = 0, f = 0;
    int i = 0;
    //Input seed used to generate random numbers
    cout << "Enter seed: ";
    cin >> seed;

    //Randomize
    srand(seed);

    //generate a number of students between 131 and 162 inclusive
    num_students = (rand() % 32) + 131;

    //generate a random grade between 10 and 100 inclusive
    grade = (rand() % 91) + 10;

    //initialize min and max to initial grade for later comparison
    int min = grade;
    int max = grade;

    //iterate through each student
    while(i < num_students)
    {
        if(grade < 60 && grade > 9)
        {
            //Increment "F" count if grade is less than 60
            f++;
            //Test if this grade is less than the currently stored minimum grade
            if(min > grade)
            {
                min = grade;
            }
        }
        else if(grade > 59 && grade < 75)
        {
            //Increment 'c' count if grade is between 60 and 74 inclusive
            c++;
        }
        else if(grade > 74 && grade < 85)
        {
            //Increment 'b' count if grade is between 75 and 84 inclusive
            b++;
        }
        else if(grade > 84 && grade < 101)
        {
            //Increment 'A' count if grade is greater than 84
            a++;
            //Test if this grade is greater than the currently stored maximum grade
            if(grade > max)
            {
                max = grade;
            }
        }
        else
        {
            //if the grade generated isn't in the acceptable range [10,100] then print out an error message and the grade
            cout << grade << " is out of range" << endl;
        }
        //randomly generate another grade between 10 and 100 inclusive, then increment the iteration variable
        grade = (rand() % 91) + 10;
        i++;
    }
    //Print out the number of students, number of each grade, and the highest and lowest grade
    cout << "There are " << num_students << " students in the class" << endl;
    cout << "A: " << a << endl;
    cout << "B: " << b << endl;
    cout << "C: " << c << endl;
    cout << "F: " << f << endl;
    cout << "The highest grade is: " << max << endl;
    cout << "The lowest grade is: " << min << endl;
    return 0;
}
